The demonstration will do the following:
1) Load the Earthquake Catalogue
2) Explore Basic Functions for Investigating and Visualising the Properties of the Catalogue
In [1]:
# Python Numerical and Plotting Libraries
import numpy as np
import matplotlib.pyplot as plt
# HMTK Catalogue Import/Export Libraries
from hmtk.parsers.catalogue.csv_catalogue_parser import CsvCatalogueParser, CsvCatalogueWriter
# HMTK Plotting Tools
from hmtk.plotting.seismicity.catalogue_plots import (plot_depth_histogram,
plot_magnitude_time_scatter,
plot_magnitude_time_density,
plot_magnitude_depth_density,
plot_observed_recurrence)
from hmtk.plotting.mapping import HMTKBaseMap
print 'Imports OK!'
In [2]:
input_catalogue_file = 'input_data/Aegean_ExtendedCat1.csv'
parser = CsvCatalogueParser(input_catalogue_file)
catalogue = parser.read_file()
print 'Input complete: %s events in catalogue' % catalogue.get_number_events()
print 'Catalogue Covers the Period: %s to %s' % (catalogue.start_year, catalogue.end_year)
In [3]:
# Sort catalogue chronologically
catalogue.sort_catalogue_chronologically()
print 'Catalogue sorted chronologically!'
In [4]:
# Configure the limits of the map and the coastline resolution
map_config = {'min_lon': 18.0, 'max_lon': 32.0, 'min_lat': 33.0, 'max_lat': 43.0, 'resolution':'h'}
# Create a hmtk basemap
basemap1 = HMTKBaseMap(map_config, 'Earthquake Catalogue')
# Add a catalogue
basemap1.add_catalogue(catalogue)
The following is an area source model for the Aegean region (Weatherill & Burton, 2010) - this source model will be used in further examples
In [5]:
# Source Model file
source_model_file = 'input_data/WT2006_Aegean_Sources.xml'
# Import the source model parser
from hmtk.parsers.source_model.nrml04_parser import nrmlSourceModelParser
# Load source model
parser = nrmlSourceModelParser(source_model_file)
source_model = parser.read_file()
# Create a hmtk basemap with a catalogue and source model
basemap2 = HMTKBaseMap(map_config, 'Earthquake Catalogue & Area Source Model')
basemap2.add_catalogue(catalogue, overlay=True) # Adds the catalogue
basemap2.add_source_model(source_model, area_border='r-', border_width=1.5) # Adds the source model
In [6]:
# Show distribution of magnitudes with time
plot_magnitude_time_scatter(catalogue, fmt_string='.')
In [7]:
# Add some error-bars
plot_magnitude_time_scatter(catalogue, plot_error=True, fmt_string='.')
In [8]:
# Plot the magnitude-time density
magnitude_bin = 0.1
time_bin = 1.0 # in Decimal Years
plot_magnitude_time_density(catalogue, magnitude_bin, time_bin)
In [9]:
# Depth histogram
plot_depth_histogram(catalogue, 5.)
In [10]:
# Depth histogram (with bootstrap sampling depth uncertainty)
depth_bin = 5.0 # in km
plot_depth_histogram(catalogue, depth_bin, bootstrap=500)
In [11]:
# Magnitude Depth Density
magnitude_bin = 0.1
depth_bin = 5.0 # in km
plot_magnitude_depth_density(catalogue, magnitude_bin, depth_bin, logscale=True)
In [12]:
# Time-varying completeness
completeness = np.array([[1985., 4.0],
[1964., 5.0],
[1910., 6.5]])
plot_observed_recurrence(catalogue, completeness, 0.1, catalogue.end_year)
In [13]:
# Limit the catalogue to the time period 1960 - 2012
valid_time = np.logical_and(catalogue.data['year'] >= 1960,
catalogue.data['year'] <= 2012)
catalogue.select_catalogue_events(valid_time)
plot_magnitude_time_density(catalogue, 0.1, 1.0)
print 'Catalogue now contains %s events' % catalogue.get_number_events()
In [14]:
# Limit the catalogue to depths less than 50 km
valid_depth = catalogue.data['depth'] <= 50.
catalogue.select_catalogue_events(valid_depth)
plot_depth_histogram(catalogue, 2.0)
In [15]:
# Set-up the file writer
output_file_name = 'output_data/basic_demo_catalogue_1.csv'
writer = CsvCatalogueWriter(output_file_name)
# Write the catalogue to file
writer.write_file(catalogue)
print 'File %s written' % output_file_name
In [16]:
completeness = np.array([[1985., 4.0],
[1964., 5.0],
[1910., 6.5]])
# Set-up the exporter
output_file_name = 'output_data/basic_demo_catalogue_complete_1.csv'
writer = CsvCatalogueWriter(output_file_name)
# Write the catalogue to file, purging events from the incomplete period
writer.write_file(catalogue, magnitude_table=completeness)
print 'File %s written' % output_file_name